package com.smart.community.work.dto;

import java.math.BigDecimal;
import java.time.LocalDateTime;

import javax.validation.constraints.DecimalMax;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.smart.community.commons.base.BaseDTO;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 请假记录DTO
 *
 * @author Wu.Liang
 * @since 2025-01-30
 * @version 1.0.0
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "请假记录DTO")
public class LeaveDTO extends BaseDTO {
    /**
	 * @author Wu.Liang
	 * @date 2025年9月14日
	 */
	private static final long serialVersionUID = 996734765987803149L;

	@Schema(description = "用户ID", example = "1")
    @NotNull(message = "用户ID不能为空")
    private Long userId;

    @Schema(description = "物业公司ID", example = "1")
    @NotNull(message = "物业公司ID不能为空")
    private Long propertyCompanyId;

    @Schema(description = "请假类型：0-事假，1-病假，2-年假，3-调休", example = "0")
    @NotNull(message = "请假类型不能为空")
    @Min(value = 0, message = "请假类型必须在0-3之间")
    @Max(value = 3, message = "请假类型必须在0-3之间")
    private Integer leaveType;

    @Schema(description = "请假开始时间", example = "2025-01-30 09:00:00")
    @NotNull(message = "请假开始时间不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime startTime;

    @Schema(description = "请假结束时间", example = "2025-01-30 18:00:00")
    @NotNull(message = "请假结束时间不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime endTime;

    @Schema(description = "请假时长（小时）", example = "8.0")
    @NotNull(message = "请假时长不能为空")
    @DecimalMin(value = "0.5", message = "请假时长不能少于0.5小时")
    @DecimalMax(value = "720", message = "请假时长不能超过720小时")
    private BigDecimal duration;

    @Schema(description = "请假原因", example = "家中有事需要处理")
    @NotBlank(message = "请假原因不能为空")
    @Size(max = 500, message = "请假原因不能超过500个字符")
    private String reason;

    @Schema(description = "审批状态：0-待审批，1-已批准，2-已拒绝", example = "0")
    private Integer status = 0;

    @Schema(description = "审批人ID", example = "2")
    private Long approverId;

    @Schema(description = "审批时间", example = "2025-01-30 10:00:00")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime approveTime;

    @Schema(description = "审批备注", example = "同意请假申请")
    @Size(max = 255, message = "审批备注不能超过255个字符")
    private String approveRemark;

    // 查询条件字段
    @Schema(description = "查询开始时间", example = "2025-01-01")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private String queryStartDate;

    @Schema(description = "查询结束时间", example = "2025-01-31")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private String queryEndDate;

    @Schema(description = "用户名", example = "张三")
    private String username;

    @Schema(description = "审批人姓名", example = "李经理")
    private String approverName;

    @Schema(description = "请假类型名称", example = "事假")
    private String leaveTypeName;
}
